import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue';
import * as path from "path";

export default ({mode, command}) => {
    const env = loadEnv(mode, process.cwd());
    return {
        plugins: [vue()],
        resolve: {
            alias: {
                '@': path.resolve(__dirname, './src')
            }
        },
        server: {
            port: Number(env.VITE_DEV_SERVER_PORT ?? 5173),
            strictPort: true,

            // 代理服务器
            proxy: {
                // 真实接口
                "^/api": {
                    target: env.VITE_BACKEND_SERVER_URL ?? "http://localhost:8080",
                    secure: false,
                    changeOrigin: true,
                },
            }
        },
        css: {
            preprocessorOptions: {
                less: {
                    // 修改 antd 的主题样式 (less变量替换)
                    modifyVars: {
                        'success-color': "#36b8a7"
                    },
                    javascriptEnabled: true,
                },
            },

        },
    }
}